home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / c / gedindent.lha / sourceindent.ged < prev   
Text File  |  1994-07-17  |  1KB  |  46 lines

  1. /* $VER: 1.0, ©1994 Michael Bauer - Indent a C sourcefile */
  2.  
  3. OPTIONS RESULTS                             /* enable return codes     */
  4.  
  5. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  6.     address 'GOLDED.1'
  7.  
  8. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  9. OPTIONS FAILAT 6                            /* ignore warnings         */
  10. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  11.  
  12. /* Mark the whole text as one block */
  13. 'MARK HIDE'     /* Delete existing mark */
  14. 'PING 0'        /* Store current cursor position */
  15. 'GOTO TOP'      /* Move to the top of the file */
  16. 'MARK SET'      /* Set the mark */
  17. 'GOTO BOTTOM'   /* Move to the bottom of the file */
  18. 'MARK SET'      /* Set the mark */
  19.  
  20. /* Name the marked block and save it */
  21. 'SAVE BLOCK NAME="dtmp:golded.indent"'
  22.  
  23. /* Indent the saved code */
  24. SHELL
  25. 'indent -br -i4 -sob -sc -npsl -o dtmp:golded.new dtmp:golded.indent'
  26. SHELL
  27.  
  28. 'DELETE BLOCK'
  29.  
  30. 'OPEN NAME="dtmp:golded.new" INSERT'
  31.  
  32. SHELL
  33. 'delete dtmp:golded.#?'
  34. SHELL
  35.  
  36. 'PONG 0'
  37.  
  38. 'UNLOCK' /* VERY important: unlock GUI */
  39. EXIT
  40.  
  41. SYNTAX:
  42.  
  43. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  44. 'UNLOCK'
  45. EXIT
  46.